From 76343567e2e84975b06a1ba71d5a0a79a6a1d778 Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Wed, 25 Mar 2026 15:32:10 +0000 Subject: [PATCH] [PATCH] freetype: Handle failing glyph rendering When FT_Render_Glpyh fails the slot returns a bitmap containing a valid width and height but a null buffer. When we eventually memcpy this buffer we will crash. Existing error handling in this method returns null on errors. Pick-to: 6.10 6.8 Fixes: QTBUG-145310 Change-Id: I4737ab4d769b52f42bd1ef9037c8b9fd681a4ae8 Reviewed-by: Eskil Abrahamsen Blomfeldt (cherry picked from commit 1b4f4b1797bc7db3eea6ef83a34df61d7bf78e17) Reviewed-by: Qt Cherry-pick Bot Gbp-Pq: Name upstream_freetype-handle-failing-glyph-rendering.patch --- src/gui/text/freetype/qfontengine_ft.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/gui/text/freetype/qfontengine_ft.cpp b/src/gui/text/freetype/qfontengine_ft.cpp index e331a4cc8..371e01db5 100644 --- a/src/gui/text/freetype/qfontengine_ft.cpp +++ b/src/gui/text/freetype/qfontengine_ft.cpp @@ -1955,11 +1955,13 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph, FT_Library_SetLcdFilter(slot->library, (FT_LcdFilter)lcdFilterType); err = FT_Render_Glyph(slot, renderMode); - if (err != FT_Err_Ok) - qWarning("render glyph failed err=%x face=%p, glyph=%d", err, face, glyph); - FT_Library_SetLcdFilter(slot->library, FT_LCD_FILTER_NONE); + if (err != FT_Err_Ok) { + qWarning("render glyph failed err=%x face=%p, glyph=%d", err, face, glyph); + return nullptr; + } + info.height = slot->bitmap.rows; info.width = slot->bitmap.width; info.x = slot->bitmap_left; -- 2.30.2